package com.osi.project.common.enums;

import com.osi.start.common.business.anno.SwaggerDisplayEnum;
import com.osi.start.common.business.enums.KeyValueEnum;

/**
 * 处理状态 10待处理，12处理中，13处理失败，14处理成功
 */
@SwaggerDisplayEnum(valueName = "key", descName = "value")
public enum HandleStatusEnum implements KeyValueEnum {

    NOT_HANDLE(0, "暂不处理"),
    WAIT(10, "待处理"),
    ING(12, "处理中"),
    FAIL(13, "处理失败"),
    SUCCESS(14, "处理成功"),

    CONFIRM_FAIL(23, "确认失败"),
    CONFIRM_SUCCESS(24, "确认成功"),


    ;


    private Integer key;
    private String value;

    HandleStatusEnum(Integer key, String value) {
        this.key = key;
        this.value = value;
    }

    @Override
    public Integer getKey() {
        return key;
    }

    @Override
    public String getValue() {
        return value;
    }


    /**
     * 功能：从key名获得 枚举对象
     * @param key
     * @return
     */
    public static HandleStatusEnum getEnum(Integer key) {
        for (HandleStatusEnum c : HandleStatusEnum.values()) {
            if (c.getKey().equals(key)) {
                return c;
            }
        }
        return null;
    }

    public Boolean isEnd() {
        if (key > ING.getKey()) {
            return true;
        }
        return false;
    }

}
